home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / gamesmaster / source / asm / screendemos / redimension.s < prev    next >
Encoding:
Text File  |  1996-09-11  |  4.5 KB  |  178 lines

  1. ;Alteration of screen dimensions
  2. ;-------------------------------
  3. ;Just a test routine for height and width alteration.  Move the joystick
  4. ;around to move the entire screen, while moving the mouse to alter the
  5. ;height and width.
  6. ;
  7. ;Press LMB to exit.
  8.  
  9.     opt    o+
  10.  
  11.     INCLUDE    "exec/exec_lib.i"
  12.     INCLUDE    "games/games_lib.i"
  13.     INCLUDE    "games/games.i
  14.  
  15. CALL    MACRO
  16.     jsr    _LVO\1(a6)
  17.     ENDM
  18.  
  19.     SECTION    "Redimension",CODE
  20.  
  21. ;===========================================================================;
  22. ;                             INITIALISE DEMO
  23. ;===========================================================================;
  24.  
  25. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  26.     move.l    ($4).w,a6
  27.     lea    GMS_Name(pc),a1
  28.     moveq    #$00,d0
  29.     CALL    OpenLibrary
  30.     move.l    d0,GMS_Base
  31.     beq    Quit
  32.  
  33.     move.l    GMS_Base(pc),a6
  34.     CALL    SetUserPri
  35.  
  36.     lea    ScreenStruct(pc),a0
  37.     CALL    Add_Screen
  38.     tst.l    d0
  39.     bne    Error
  40.  
  41.     lea    Picture(pc),a1    ;a1 = Picture struct.
  42.     move.l    SS_MemPtr1(a0),PIC_Data(a1)
  43.     lea    PicFile(pc),a0    ;a0 = Picture file.
  44.     CALL    LoadPic    ;>> = Load the picture.
  45.     tst.w    d0
  46.     bne    ReturnToDOS
  47.  
  48.     lea    ScreenStruct(pc),a0      ;Now show the screen/pic.
  49.     CALL    Show_Screen
  50.  
  51. ;===========================================================================;
  52. ;                                MAIN LOOP
  53. ;===========================================================================;
  54.  
  55. Loop:    moveq    #JPORT1,d0               ;Read from port 1
  56.     moveq    #JT_ZBXY,d1
  57.     CALL    Read_JoyPort             ;Go get port status.
  58.     btst    #MB_LMB,d0
  59.     bne    Fade_Here
  60.     move.w    d0,d1
  61.     ext.w    d0
  62.     asr.w    #8,d1
  63.     add.w    d1,SS_ScrWidth(a0)
  64.     add.w    d0,SS_ScrHeight(a0)
  65.  
  66.     moveq    #JPORT2,d0               ;Read from port 2
  67.     moveq    #JT_ZBXY,d1
  68.     CALL    Read_JoyPort             ;Go get port status.
  69.     btst    #JB_FIRE1,d0
  70.     bne.s    Fade_Here
  71.     move.w    d0,d1
  72.     ext.w    d0
  73.     asr.w    #8,d1
  74.     add.w    d1,SS_ScrXOffset(a0)
  75.     add.w    d0,SS_ScrYOffset(a0)
  76.  
  77. .chksrx    cmp.w    #35,SS_ScrXOffset(a0)
  78.     ble.s    .chkslx
  79.     move.w    #35,SS_ScrXOffset(a0)
  80.  
  81. .chkslx    cmp.w    #-40,SS_ScrXOffset(a0)
  82.     bge.s    .chksty
  83.     move.w    #-40,SS_ScrXOffset(a0)
  84.  
  85. .chksty    cmp.w    #-20,SS_ScrYOffset(a0)
  86.     bge.s    .chkty
  87.     move.w    #-20,SS_ScrYOffset(a0)
  88.  
  89. .chkty    tst.w    SS_ScrHeight(a0)
  90.     bge.s    .chkby
  91.     clr.w    SS_ScrHeight(a0)
  92.  
  93. .chkby    cmp.w    #256,SS_ScrHeight(a0)
  94.     ble.s    .chklx
  95.     move.w    #256,SS_ScrHeight(a0)
  96.  
  97. .chklx    cmp.w    #1,SS_ScrWidth(a0)
  98.     bge.s    .chkrx
  99.     move.w    #1,SS_ScrWidth(a0)
  100.  
  101. .chkrx    cmp.w    #320,SS_ScrWidth(a0)
  102.     ble.s    .done
  103.     move.w    #320,SS_ScrWidth(a0)
  104.  
  105. .done    CALL    Wait_OSVBL               ;Always wait for a VBL first.
  106.     CALL    Remake_Screen            ;Reposition the screen now.
  107.     bra    Loop
  108.  
  109. Fade_Here:
  110.     moveq    #$00,d0
  111. .Fade    CALL    Wait_OSVBL               ;Keep looping until the fade is
  112.     CALL    B12_FadeToBlack          ;completely finished (ie all
  113.     tst.w    d0                       ;colours are black).
  114.     bne.s    .Fade
  115.  
  116. ;===========================================================================;
  117. ;                              RETURN TO DOS
  118. ;===========================================================================;
  119.  
  120. ReturnToDOS:
  121.     move.l    GMS_Base(pc),a6
  122.     lea    ScreenStruct(pc),a0
  123.     CALL    Delete_Screen            ;Give back screen memory etc.
  124. Error:    move.l    GMS_Base(pc),a1
  125.     move.l    ($4).w,a6
  126.     CALL    CloseLibrary
  127. Quit:    MOVEM.L    (SP)+,A0-A6/D1-D7
  128.     moveq    #$00,d0
  129.     rts
  130.  
  131. ;===========================================================================;
  132. ;                           CODE-RELATIVE DATA
  133. ;===========================================================================;
  134.  
  135. GMS_Name:
  136.     dc.b    "games.library",0
  137.     even
  138. GMS_Base:
  139.     dc.l    0
  140.  
  141. AMT_PLANES =    5
  142.  
  143. ScreenStruct:
  144.     dc.l    "GSV1",0
  145.     dc.l    0,0,0            ;Screen_Mem1/2/3
  146.     dc.l    0                ;Screen link.
  147.     dc.l    Palette          ;Address of screen palette
  148.     dc.l    0                ;Address of rasterlist.
  149.     dc.l    0                ;Amt of colours in palette.
  150.     dc.w    320,256,320,256  ;Screen & Pic Height/Width
  151.     dc.w    AMT_PLANES       ;Amt_Planes
  152.     dc.w    0,0              ;X/Y screen offset
  153.     dc.w    0,0              ;X/Y picture offset
  154.     dc.l    0                ;Special attributes
  155.     dc.w    LORES            ;Screen mode
  156.     dc.b    INTERLEAVED      ;Screen type
  157.     dc.b    0                ;Reserved
  158.     even
  159.  
  160. Palette    dc.w    $0000,$0130,$0FCB,$0FA9,$0D88,$0965,$0644,$0211
  161.     dc.w    $0400,$0444,$0FF0,$0432,$0CC0,$0150,$0501,$0880
  162.     dc.w    $0261,$0271,$0382,$0492,$05A3,$05B4,$0677,$06C4
  163.     dc.w    $0788,$09AA,$0BCC,$0801,$0901,$0A02,$0701,$0601
  164.  
  165. Picture    dc.l    "PCV1",0    ;Version header.
  166.     dc.l    0    ;Source data.
  167.     dc.w    320,256    ;Width, Height.
  168.     dc.w    AMT_PLANES    ;Amount of Planes.
  169.     dc.l    32    ;Amount of colours.
  170.     dc.l    Palette    ;Source palette (remap).
  171.     dc.w    LORES    ;Screen mode.
  172.     dc.w    INTERLEAVED    ;Destination
  173.     dc.l    0    ;Parameters.
  174.  
  175. PicFile    dc.b    "GAMESLIB:data/IFF.Pic320",0
  176.     even
  177.  
  178.